package cn.funnyxb.powerremember.uis.task.done.study;

import android.content.Context;
import android.database.Cursor;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.SimpleCursorAdapter;
import android.widget.TextView;
import android.widget.Toast;
import cn.funnyxb.powerremember.db.tables.Tbholder_taskWithWords;
import cn.funnyxb.tools.appFrame.App;
import cn.funnyxb.tools.appFrame.debugTool.Debuger;

public class CursorAdapter_4Study extends SimpleCursorAdapter
{
  private StudyConfiger config;
  private Context context;
  private Cursor cursor;
  private int[] difficulty;
  private String[] from;
  private View[] holder;
  private boolean[] isClicked;
  private View.OnClickListener itemBtnOnClickListener = new 1(this);
  private int mStyle = 0;
  private Tbholder_taskWithWords tbholder_task;
  private int[] to;

  public CursorAdapter_4Study(Context paramContext, int paramInt, Cursor paramCursor, String[] paramArrayOfString, int[] paramArrayOfInt, StudyConfiger paramStudyConfiger, Tbholder_taskWithWords paramTbholder_taskWithWords)
  {
    super(paramContext, paramInt, paramCursor, paramArrayOfString, paramArrayOfInt);
    freashDataHold(paramCursor.getCount());
    this.context = paramContext;
    this.cursor = paramCursor;
    this.from = paramArrayOfString;
    this.to = paramArrayOfInt;
    this.config = paramStudyConfiger;
    this.tbholder_task = paramTbholder_taskWithWords;
    this.mStyle = paramStudyConfiger.getShowStyleId();
  }

  private void freashDataHold(int paramInt)
  {
    this.holder = new View[paramInt];
    this.isClicked = new boolean[paramInt];
    this.difficulty = new int[paramInt];
    for (int i = 0; ; ++i)
    {
      if (i >= this.difficulty.length)
        return;
      this.difficulty[i] = -1;
    }
  }

  private void freashItemview(View paramView, int paramInt)
  {
    Cursor localCursor = this.cursor;
    localCursor.moveToPosition(paramInt);
    int i = 0;
    label16: int k;
    int j;
    label113: int l;
    label166: View localView5;
    int i1;
    if (i >= this.from.length)
    {
      ((Button)paramView.findViewById(2131165278)).setTag(Integer.valueOf(paramInt));
      ((Button)paramView.findViewById(2131165276)).setTag(Integer.valueOf(paramInt));
      if (this.difficulty[paramInt] >= 0)
        ((TextView)paramView.findViewById(2131165277)).setText(this.difficulty[paramInt]);
      if (this.isClicked[paramInt] == 0)
        break label291;
      k = 0;
      j = 0;
      View localView1 = paramView.findViewById(2131165275);
      if (localView1 != null)
        localView1.setVisibility(j);
      View localView2 = paramView.findViewById(2131165280);
      if (localView2 != null)
        localView2.setVisibility(k);
      if (!(this.config.isEnableAdjustDifficultyByBtn()))
        break label335;
      l = 0;
      View localView3 = paramView.findViewById(2131165278);
      if (localView3 != null)
        localView3.setVisibility(l);
      View localView4 = paramView.findViewById(2131165276);
      if (localView4 != null)
        localView4.setVisibility(l);
      localView5 = paramView.findViewById(2131165279);
      if (!(this.config.isShowPhoneticAfterClick()))
        break label348;
      if (localView5 != null)
      {
        if (this.isClicked[paramInt] == 0)
          break label342;
        i1 = 0;
        label241: localView5.setVisibility(i1);
      }
    }
    while (true)
    {
      return;
      ((TextView)paramView.findViewById(this.to[i])).setText(localCursor.getString(localCursor.getColumnIndex(this.from[i])));
      ++i;
      break label16:
      if (this.config.getMode() == 2)
      {
        label291: j = 4;
        label305: if (this.config.getMode() != 3)
          break label329;
      }
      for (k = 8; ; k = 0)
      {
        break label113:
        j = 0;
        label329: break label305:
      }
      label335: l = 8;
      break label166:
      label342: i1 = 4;
      break label241:
      label348: if (localView5 == null)
        continue;
      localView5.setVisibility(0);
    }
  }

  private void log(String paramString)
  {
    Debuger.log("adapter_study", paramString);
  }

  public void adjustDifficulty(Context paramContext, int paramInt1, int paramInt2, Tbholder_taskWithWords paramTbholder_taskWithWords)
  {
    log("adjustdiff,index=" + paramInt1 + ",adjust=" + paramInt2);
    if (paramInt1 >= this.difficulty.length);
    while (true)
    {
      return;
      int i = paramInt2 + this.difficulty[paramInt1];
      log("newDiff=" + i);
      if (i < 0)
        Toast.makeText(paramContext, 2131034304, 0).show();
      if (i > 9)
        Toast.makeText(paramContext, 2131034305, 0).show();
      this.difficulty[paramInt1] = i;
      View localView = this.holder[paramInt1];
      ((TextView)localView.findViewById(2131165277)).setText(i);
      paramTbholder_taskWithWords.updateDifficulty(Integer.parseInt(((TextView)localView.findViewById(2131165274)).getText()), i);
    }
  }

  public void changeConfig(StudyConfiger paramStudyConfiger)
  {
    this.config = paramStudyConfiger;
    notifyDataSetChanged();
  }

  public void changeCursor(Cursor paramCursor)
  {
    if (paramCursor == null);
    while (true)
    {
      return;
      freashDataHold(paramCursor.getCount());
      this.cursor = paramCursor;
      super.changeCursor(paramCursor);
    }
  }

  public View getView(int paramInt, View paramView, ViewGroup paramViewGroup)
  {
    Log.i("temp", "getView,pos=" + paramInt);
    int i;
    label180: int j;
    if (paramView == null)
    {
      Log.i("temp", "newView getView,pos=" + paramInt);
      paramView = super.getView(paramInt, paramView, paramViewGroup);
      ((TextView)paramView.findViewById(2131165279)).setTypeface(App.getApp().getMyTypeface());
      TextView localTextView = (TextView)paramView.findViewById(2131165277);
      Log.i("temp3", "height=" + localTextView.getHeight());
      this.difficulty[paramInt] = Integer.parseInt(localTextView.getText());
      Button localButton1 = (Button)paramView.findViewById(2131165278);
      localButton1.setOnClickListener(this.itemBtnOnClickListener);
      localButton1.setTag(Integer.valueOf(paramInt));
      if (!(this.config.isEnableAdjustDifficultyByBtn()))
        break label331;
      i = 0;
      localButton1.setVisibility(i);
      Button localButton2 = (Button)paramView.findViewById(2131165276);
      localButton2.setOnClickListener(this.itemBtnOnClickListener);
      localButton2.setTag(Integer.valueOf(paramInt));
      if (!(this.config.isEnableAdjustDifficultyByBtn()))
        break label338;
      j = 0;
      label229: localButton2.setVisibility(j);
    }
    if (this.difficulty[paramInt] < 0)
    {
      this.cursor.moveToPosition(paramInt);
      this.difficulty[paramInt] = this.cursor.getInt(this.cursor.getColumnIndex("difficulty"));
    }
    switch (this.mStyle)
    {
    default:
    case 0:
    case 1:
    case 2:
    case 3:
    }
    while (true)
    {
      freashItemview(paramView, paramInt);
      this.holder[paramInt] = paramView;
      return paramView;
      label331: i = 8;
      break label180:
      label338: j = 8;
      break label229:
      paramView.setBackgroundDrawable(null);
      paramView.setPadding(1, 5, 1, 5);
      continue;
      paramView.setBackgroundResource(17301654);
      continue;
      if (paramInt % 2 == 0)
      {
        paramView.setBackgroundDrawable(null);
        paramView.setPadding(1, 5, 1, 5);
      }
      paramView.setBackgroundResource(2130837514);
      paramView.setPadding(1, 5, 1, 5);
      continue;
      if (paramInt % 2 == 0)
      {
        paramView.setBackgroundDrawable(null);
        paramView.setPadding(1, 5, 1, 5);
      }
      paramView.setBackgroundResource(2130837513);
      paramView.setPadding(1, 5, 1, 5);
    }
  }

  public String getWord(int paramInt)
  {
    if (paramInt >= this.cursor.getCount());
    for (String str = null; ; str = this.cursor.getString(this.cursor.getColumnIndex("word")))
    {
      return str;
      this.cursor.moveToPosition(paramInt);
    }
  }

  public void notifyClick(View paramView, int paramInt)
  {
    this.isClicked[paramInt] = true;
    if (this.config.getMode() == 2)
      paramView.findViewById(2131165275).setVisibility(0);
    while (true)
    {
      if (this.config.isShowPhoneticAfterClick())
        paramView.findViewById(2131165279).setVisibility(0);
      return;
      if (this.config.getMode() != 3)
        continue;
      paramView.findViewById(2131165280).setVisibility(0);
    }
  }

  public void notifyConfigChanged()
  {
    freashDataHold(this.cursor.getCount());
    notifyDataSetChanged();
  }

  public void turnStyle()
  {
    this.mStyle = ((1 + this.mStyle) % 4);
    this.config.setShowStyleId(this.mStyle);
    notifyDataSetChanged();
  }
}

/* Location:           E:\Desktop\复件 classes_dex2jar.jar
 * Qualified Name:     cn.funnyxb.powerremember.uis.task.done.study.CursorAdapter_4Study
 * JD-Core Version:    0.5.3
 */